from django.urls import path, re_path, register_converter
from rest_framework.routers import DefaultRouter

from utils import converters
from . import views

register_converter(converters.UserRelationConverter, 'relations')
urlpatterns = [
    path('authorizations/', views.MyJsonWebTokenAPIView.as_view()),
    path('refreshtoken/', views.MyRefreshJSONWebToken.as_view()),
    path('avatar/', views.QiNiuAvatarUploadView.as_view()),
    re_path(r'^tlike/(?P<target>\d+)/?$', views.LikeTeacherView.as_view()),
    re_path(r'^tfollow/(?P<target>\d+)/?$', views.FollowTeacherView.as_view()),
    re_path(r'^ufollow/(?P<target>\d+)/?$', views.FollowUserView.as_view()),
    path('username/<username>/', views.UserNameCountView.as_view()),
    path('users/<relations:type>/<int:user_id>/', views.UserRelationListView.as_view()),
]

router = DefaultRouter()
router.register(r'profile', views.ProfileView, basename='')
router.register(r'teacher', views.TeacherModelViewSet, basename='')
urlpatterns += router.urls
